package main.java.tutorial.springmvc.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class MyInterceptor implements HandlerInterceptor{
	
	private String myParam;

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		System.out.println("MyInterceptor --> preHandle;"+ "myParam: "+myParam);
		
		//Ritornando true il flusso prosegue, altrimenti si interrompe
		return true;
	}

	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		System.out.println("MyInterceptor --> postHandle;"+ "myParam: "+myParam);
		
	}

	@Override
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		System.out.println("MyInterceptor --> afterCompletion;"+ "myParam: "+myParam);
		
	}

	public String getMyParam() {
		return myParam;
	}

	public void setMyParam(String myParam) {
		this.myParam = myParam;
	}
	
	


}
